package com.fts.fts.fitness_tracking_system.pojo;

import java.util.List;

// 数据传输对象
public record VideoDetailDTO(
        Integer id,
        String title,
        String description,
        Integer duration,
        String coverUrl,
        String videoUrl,
        List<SegmentDTO> segments
) {
    public VideoDetailDTO(Video video, List<VideoSegment> segments) {
        this(
                video.getId(),
                video.getTitle(),
                video.getDescription(),
                video.getDuration(),
                video.getCoverUrl(),
                video.getVideoUrl(),
                segments.stream()
                        .map(s -> new SegmentDTO(
                                s.getId(),
                                s.getSegmentName(),
                                s.getStartTime(),
                                s.getEndTime(),
                                s.getThumbnail()
                        )).toList()
        );
    }

    public record SegmentDTO(
            Integer segmentId,
            String segmentName,
            Double startTime,
            Double endTime,
            String thumbnail
    ) {
    }
}